using System;
using System.Collections.Generic;
using dbvc.data;
using dbvc.Queries;

namespace dbvc.context.Project
{
    public static partial class Project
    {
        public static void Delete(this db_project self)
        {
            GenericQuery<db_project>.Delete(self);
        }
    }

    public class DeleteProject
    {
        private readonly IEnumerable<db_project> projects;
        private readonly db_user user;
        private db_activity Activity;

        public DeleteProject(db_user _principal, IEnumerable<db_project> _projects)
        {
            user = _principal;
            projects = _projects;
        }

        public void Execute()
        {
            foreach (db_project prj in projects)
            {
                Activity = new db_activity {action = "delete project", datestamp = DateTime.Now, userstamp = user.name};
                prj.Delete();
                Activity.Save();
            }
        }
    }
}